<?php

namespace App\Http\Controllers\OpenShop\SiteLocation;

use App\Http\Controllers\BaseController;
use App\Service\Common\AreaService;
use Illuminate\Http\Request;

class AreaController extends BaseController
{
    public function getAreaCodeByArea(Request $request)
    {
        $this->validate($request, [
            'lng' => 'required',
            'lat' => 'required',
        ]);
        $lng = $request->get('lng', 0);
        $lat = $request->get('lat', 0);
        return $this->success(AreaService::getAreaCodeByArea($lng, $lat));
    }

    public function getCityGradeByCityCode(Request $request)
    {
        $this->validate($request, [
            'cityCode' => 'required',
        ]);
        $cityCode = $request->get('cityCode', 0);
        return $this->success(AreaService::getCityGradeByCityCode($cityCode));
    }

}
